#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "IntervalConstraint.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class DurationInterval;

/// <summary>
/// DurationConstraint
/// A DurationConstraint is a Constraint that refers to a DurationInterval.
/// </summary>
class UMLMODEL_EXPORT DurationConstraint : public IntervalConstraint {

public: // Constructors and destructors
    explicit DurationConstraint(const QString& umlType="uml::DurationConstraint");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Properties
    /// <summary>
    /// firstEvents getter
    /// The value of firstEvent[i] is related to constrainedElement[i] (where i is 1 or
    /// 2). If firstEvent[i] is true, then the corresponding observation event is the
    /// first time instant the execution enters constrainedElement[i]. If firstEvent[i]
    /// is false, then the corresponding observation event is the last time instant the
    /// execution is within constrainedElement[i].
    /// </summary>
    vector<bool>& firstEvents();

    /// <summary>
    /// specification getter
    /// The DurationInterval constraining the duration.
    /// </summary>
    shared_ptr<DurationInterval> specification() const;

    /// <summary>
    /// specification setter
    /// The DurationInterval constraining the duration.
    /// </summary>
    void setSpecification(shared_ptr<DurationInterval> value);

private: // Fields
    /// <summary>
    /// firstEvents
    /// The value of firstEvent[i] is related to constrainedElement[i] (where i is 1 or
    /// 2). If firstEvent[i] is true, then the corresponding observation event is the
    /// first time instant the execution enters constrainedElement[i]. If firstEvent[i]
    /// is false, then the corresponding observation event is the last time instant the
    /// execution is within constrainedElement[i].
    /// </summary>
    vector<bool> firstEvents_;

    /// <summary>
    /// specification
    /// The DurationInterval constraining the duration.
    /// </summary>
    shared_ptr<DurationInterval> specification_;

};

} // namespace uml
